package com.zerui.manager.app.accessauthpersonnel.executer;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.zerui.cola.dto.Response;
import com.zerui.manager.accessauthdevice.domainservice.AccessAuthDeviceRepository;
import com.zerui.manager.accessauthpersonnel.domainservice.AccessAuthPersonnelRepository;
import com.zerui.manager.web.cmd.AccessAuthPersonnelBindCmd;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wh
 * @create_time 2023-08-30 14:55
 */
@Component
@CatchAndLog
public class AccessAuthPersonnelDelCmdExe {

    @Resource
    private AccessAuthPersonnelRepository accessAuthPersonnelRepository;

    @Resource
    private AccessAuthDeviceRepository accessAuthDeviceRepository;

    public Response execute(AccessAuthPersonnelBindCmd cmd) {
        List<Long> personnelIds = accessAuthPersonnelRepository.deleteBatch(cmd);
        accessAuthDeviceRepository.devicesDeleteDistributePermissionsByPersonals(cmd.getAccessAuthId(),personnelIds);
        return Response.buildSuccess();
    }
}
